package cn.sc.allinpay.allfavour.business.sale;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.util.List;

import cn.pai.mvp.callback.MpCallBack;
import cn.sc.allinpay.allfavour.base.connect.http.AppRequest;
import cn.sc.allinpay.allfavour.base.connect.http.RequestManager;
import cn.sc.allinpay.allfavour.base.model.BaseModel;
import cn.sc.allinpay.allfavour.business.common.data.SaleCouponData;

/**
 * 售券
 * author：pany
 * on 2017/12/5 14:44
 */
public class SaleModel extends BaseModel {

    /**
     * 售券列表查询接口
     *
     * @param mpCallBack
     */
    public void reqQrySaleCoupon(final MpCallBack<List<SaleCouponData>, String> mpCallBack) {
        RequestManager.reqQrySaleCoupon(new AppRequest.RequestCall() {
            @Override
            protected void onSuccess(JSONObject response) {
                List<SaleCouponData> list = JSON.parseArray(response.getJSONObject("data").getString("lists"), SaleCouponData.class);
                mpCallBack.onSuccess(list);
            }

            @Override
            public void onFailure(JSONObject response, String message) {
                mpCallBack.onFailure((response != null ? response.toString() : null), message);
            }
        });
    }
}
